/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ejb;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author longdm0708l
 */
@Stateless
public class CompanyFacade implements CompanyFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(Company company) {
        em.persist(company);
    }

    public void edit(Company company) {
        em.merge(company);
    }

    public void remove(Company company) {
        em.remove(em.merge(company));
    }

    public Company find(Object id) {
        return em.find(Company.class, id);
    }

    public List<Company> findAll() {
        return em.createQuery("select object(o) from Company as o").getResultList();
    }

}
